from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
import time

LOAD_IMAGE = 'Load Image'
SAVE_IMAGE = 'Save Image'

Builder.load_string(f'''
<MainLayout>
    orientation:'vertical'
    spacing:5
    padding:5
    BoxLayout
        orientation:'horizontal'
        size_hint_y: None
        height: '48dp'
        spacing:5
        padding:5
        Button:
            id:btn_load
            text:'{LOAD_IMAGE}'
            on_press: root.on_btn_press(self.text)
        Button:
            id:btn_save
            text:'{SAVE_IMAGE}'
            on_press: root.on_btn_press(self.text)
    Label:
        id:label
        text: 'Please load a image'
        text_size: self.width, None
        halign: 'center'
        valign: 'middle'  # 'bottom', 'middle', 'center', 'top'
''')


class MainLayout(BoxLayout):

    def __init__(self, **kwargs):
        super(MainLayout, self).__init__(**kwargs)

    def on_btn_press(self, text):
        if LOAD_IMAGE == text:
            self.ids.label.text = 'Loaded a image!'
        elif SAVE_IMAGE == text:
            self.ids.label.text = 'Saved a image!'
        else:
            print('Something wrong ...')


class ButtonsApp(App):
    def build(self):
        return MainLayout()


if __name__ == '__main__':

    ButtonsApp().run()
